package org.gp.command.service;

import java.util.ArrayList;
import java.util.List;
import org.gp.command.entity.Command;
import org.gp.common.orm.LoadHibernate;
import org.hibernate.Session;

/**
 * @Description: TODO
 *
 * @author xiaomu [xiaomu89622@gmail.com]
 * @since
 * @version 2012-5-14 ����10:38:05
 */
public class CommandService {

    private static LoadHibernate loadHibernate;

    static {
        loadHibernate = LoadHibernate.getInstance();
    }

    public List findCommand() {
        List<Command> list=new ArrayList<Command>();
        Session session = loadHibernate.getSession();
        session.beginTransaction();
        list=session.createQuery("from Command").list();
        session.beginTransaction().commit();
        return list;
    }

    public void addCommand(Command command) {
        Session session = loadHibernate.getSession();
        session.beginTransaction();
        session.save(command);
        session.beginTransaction().commit();
    }

    public static void main(String[] args) {
        CommandService cs = new CommandService();
        Command command = new Command(); 
        command.setCommandType("");
        command.setCommandName("");
        command.setCommandParam("");
        command.setCommandExample("");
        cs.addCommand(command);
    }
}
